<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>

</head>

<body>
    <div id="div">
        {{data}}
        <button @click="fn">+</button>
    </div>
</body>
<script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
<script>
    const app = new Vue({
        el: '#div',
        data: {
            data: 100
        },

        methods: {
            fn() {
                this.data++
            }
        },
        //1.创建数据，准备数据
        beforeCreate() {
            console.log('数据准备好之前');
        },
        created() {
            console.log('数据准备好后');
        },
        //2.挂载阶段,渲染模板(dom)
        beforeMount() {
            console.log('渲染模板之前');
        },
        mounted() {
            console.log('渲染模板之后');
        },
        //3.更新阶段(数据已修改，视图未更新)
        beforeUpdate() {
            console.log('更新之前', document.querySelector('#div').innerHTML);
        },
        updated() {
            console.log('更新之后', document.querySelector('#div').innerHTML);
        },

        //4.卸载阶段
        beforeDestroy() {
            console.log('销毁之前');
        },
        destroyed() {
            console.log('销毁之后');
        },




    })
</script>

</html>